<template>
  <div class="reportFormPage">
    <div class="report-dom">
      <el-row>
        <el-col :span="5" :offset="19">
          <div class="pageNumBox">
            <span>第</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
            <span>页，共</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
            <span>页</span>
          </div>
        </el-col>
      </el-row>
      <div class="topTwoBox">
        <div class="centerName">水泥胶砂流动度、胶砂强度试验检测记录表</div>
        <div class="codeText">
          <tr>
            JGLQ04006
          </tr>
          <tr>
            JGLQ04009
          </tr>
        </div>
      </div>
      <div class="threeTopBox">
        <div class="left-border">
          <div class="box-title">检测单位名称：</div>
          <div class>{{ form.jiancdwmc }}</div>
        </div>
        <div class="right-border">
          <span>记录编号：</span>
          <span v-if="isPdf" class="placeholder">{{ form.jilbh }}</span>
          <el-input class="code-input" v-else type="text" v-model="form.jilbh" @focus="handleFocus('jilbh')" />
        </div>
      </div>
      <div class="table-border">
        <!------------------------------表头-------------------------->
        <table height="220px" class="top-table">
          <tbody>
            <tr>
              <td height="30" align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程名称</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcmc }}</span>
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程部位/用途</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcbwyt }}</span>
              </td>
            </tr>
            <tr>
              <td height="50" align="center">样品信息</td>
              <td class="specimen-border" colspan="3">
                <span>样品名称：</span>
                <span :class="{ placeholder: !form.yangpmc }">{{ form.yangpmc }}</span>
                <span>；样品编号：</span>
                <span :class="{ 'placeholder-long': !form.yangpbh }">{{ form.yangpbh }}</span>
                <span>；样品数量：</span>
                <span :class="{ placeholder: !form.yangpsl }">{{ form.yangpsl }}</span>
                <span>；样品状态：</span>
                <span :class="{ placeholder: !form.yangpzt }">{{ form.yangpzt }}</span>
                <span>；来样时间：</span>
                <span :class="{ placeholder: !form.yangpsj }">{{ form.yangpsj }}</span>
              </td>
            </tr>

            <tr>
              <td height="25" align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验检测日期</span>
              </td>
              <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->
              <td width="35%" class="text-center">
                <el-input v-model="form.shiyjcrq" />
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验条件</span>
              </td>
              <td v-if="isPdf" width="35%">
                温度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjwd }}</span>
                ℃；湿度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjsd }}</span
                >%RH
              </td>
              <td v-else width="35%">
                温度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjwd" style="width: 15%" />
                ℃；湿度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjsd" style="width: 15%" />
                %RH
              </td>
            </tr>

            <tr>
              <td height="50" align="center" width="15%">
                <span style="width: 90px; display: inline-block">检测依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.jiancyj }}</span>
                <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark" @dblclick.native="showBsJiancyjView" readonly />
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">判定依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.pandyj }}</span>
                <el-input v-else type="textarea" v-model="form.pandyj" :rows="2" @dblclick.native="showBsJudgeBaseView" @focus="handleFocus('pandyj')" class="mark" />
              </td>
            </tr>
            <tr class="bottom-border">
              <td height="50" align="center">
                <div>主要仪器设备</div>
                <div>名称及编号</div>
              </td>
              <td colspan="3">
                <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
                <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh" class="height100 width100 mark" @dblclick.native="showBsInstrumentView" readonly></el-input>
              </td>
            </tr>
          </tbody>
        </table>
        <!------------------------------表中-------------------------->
        <table height="616px" class="middle-table">
          <tbody>
            <tr height="25">
              <td colspan="8">胶砂流动度</td>
            </tr>
            <tr height="40">
              <td style="width: 5%">试验次数</td>
              <td style="width: calc(95% / 7)">
                水泥用量
                <br />(g)
              </td>
              <td style="width: calc(95% / 7)">
                标准砂用量
                <br />(g)
              </td>
              <td style="width: calc(95% / 7)">
                用水量
                <br />(g)
              </td>
              <td style="width: calc(95% / 7)">
                扩展直径
                <br />(mm)
              </td>
              <td style="width: calc(95% / 7)">
                垂直直径
                <br />(mm)
              </td>
              <td style="width: calc(95% / 7)">
                胶砂流动度
                <br />测值(mm)
              </td>
              <td style="width: calc(95% / 7)">
                胶砂流动度
                <br />测定值(mm)
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input type="text" v-model="form.jiaoslddsycs" @keydown.native="handleKeyDown($event, 0, 0)" @paste.native="handlePaste($event, 0, 0)" :ref="'0_0'" />
              </td>
              <td>
                <el-input type="number" v-model="form.jiaoslddsnyl" @keydown.native="handleKeyDown($event, 0, 1)" @paste.native="handlePaste($event, 0, 1)" :ref="'0_1'" />
              </td>
              <td>
                <el-input type="number" v-model="form.jiaoslddbzsyl" @keydown.native="handleKeyDown($event, 0, 2)" @paste.native="handlePaste($event, 0, 2)" :ref="'0_2'" />
              </td>
              <td>
                <el-input type="number" v-model="form.jiaoslddysl" @keydown.native="handleKeyDown($event, 0, 3)" @paste.native="handlePaste($event, 0, 3)" :ref="'0_3'" />
              </td>
              <td>
                <el-input type="number" v-model="form.jiaoslddkzzj" @keydown.native="handleKeyDown($event, 0, 4)" @paste.native="handlePaste($event, 0, 4)" :ref="'0_4'" />
              </td>
              <td>
                <el-input type="number" v-model="form.jiaoslddczzj" @keydown.native="handleKeyDown($event, 0, 5)" @paste.native="handlePaste($event, 0, 5)" :ref="'0_5'" />
              </td>
              <td>
                <el-input type="number" v-model="form.jiaoslddjslddcz" @keydown.native="handleKeyDown($event, 0, 6)" @paste.native="handlePaste($event, 0, 6)" :ref="'0_6'" />
              </td>
              <td>
                <el-input
                  type="number"
                  v-model="form.jiaoslddjslddcdz"
                  @change="calculateJslddcdz"
                  @keydown.native="handleKeyDown($event, 0, 7)"
                  @paste.native="handlePaste($event, 0, 7)"
                  :ref="'0_7'"
                />
              </td>
            </tr>
            <tr height="25">
              <td colspan="8">胶砂强度</td>
            </tr>
            <tr height="25">
              <td colspan="2">养护条件</td>
              <td colspan="3">
                <el-input type="text" v-model="form.jiaosqdyhtj" @keydown.native="handleKeyDown($event, 1, 0)" :ref="'1_0'" />
              </td>
              <td>成型日期</td>
              <td colspan="2" class="line-feed-date">
                <!-- <el-date-picker type="datetime" class="hide-icon" v-model="form.jiaosldcxrq" style="width: 100%" /> -->
                <el-date-picker class="hide-icon" ref="jiaosldcxrq" type="datetime" v-model="form.jiaosldcxrq" value-format="yyyy/MM/dd HH:mm" format="yyyy/MM/dd HH:mm" style="width: 100%" />
                <div class="date-view" @click="$refs.jiaosldcxrq.focus()">{{ form.jiaosldcxrq }}</div>
              </td>
            </tr>
            <tr height="25">
              <td rowspan="7">抗折强度</td>
              <td>龄期(d)</td>
              <td>试验日期</td>
              <td colspan="2">试件尺寸(mm)</td>
              <td>破坏荷载(N)</td>
              <td>单值(Mpa)</td>
              <td>平均值(Mpa)</td>
            </tr>
            <tr height="25">
              <td rowspan="3">3</td>
              <!-- <td rowspan="3">
                <el-date-picker type="datetime" class="hide-icon" v-model="form.kangzqd3syrq" style="width: 100%" />
              </td> -->
              <td rowspan="3" class="line-feed-date">
                <el-date-picker class="hide-icon" ref="kangzqd3syrq" type="datetime" v-model="form.kangzqd3syrq" value-format="yyyy/MM/dd HH:mm" format="yyyy/MM/dd HH:mm" style="width: 100%" />
                <div class="date-view" @click="$refs.kangzqd3syrq.focus()">{{ form.kangzqd3syrq }}</div>
              </td>
              <td rowspan="3" colspan="2">40*40*160</td>
              <td>
                <el-input
                  type="number"
                  v-model="form.kangzqd3phhz1"
                  @change="calculatePhhz(1, form.kangzqd3phhz1)"
                  @keydown.native="handleKeyDown($event, 2, 0)"
                  @paste.native="handlePasteTwo($event, 0, 0)"
                  :ref="'2_0'"
                />
              </td>
              <td>
                <span>{{ form.kangzqd3dz1 }}</span>
              </td>
              <td rowspan="3">
                <span>{{ form.kangzqd3pjz }}</span>
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input
                  type="number"
                  v-model="form.kangzqd3phhz2"
                  @change="calculatePhhz(2, form.kangzqd3phhz2)"
                  @keydown.native="handleKeyDown($event, 3, 0)"
                  @paste.native="handlePasteTwo($event, 1, 0)"
                  :ref="'3_0'"
                />
              </td>
              <td>
                <span>{{ form.kangzqd3dz2 }}</span>
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input
                  type="number"
                  v-model="form.kangzqd3phhz3"
                  @change="calculatePhhz(3, form.kangzqd3phhz3)"
                  @keydown.native="handleKeyDown($event, 4, 0)"
                  @paste.native="handlePasteTwo($event, 2, 0)"
                  :ref="'4_0'"
                />
              </td>
              <td>
                <span>{{ form.kangzqd3dz3 }}</span>
              </td>
            </tr>
            <tr height="25">
              <td rowspan="3">28</td>
              <td rowspan="3" class="line-feed-date">
                <!-- <el-date-picker type="datetime" class="hide-icon" v-model="form.kangzqd28syrq" style="width: 100%" /> -->

                <el-date-picker class="hide-icon" ref="kangzqd28syrq" type="datetime" v-model="form.kangzqd28syrq" value-format="yyyy/MM/dd HH:mm" format="yyyy/MM/dd HH:mm" style="width: 100%" />
                <div class="date-view" @click="$refs.kangzqd28syrq.focus()">{{ form.kangzqd28syrq }}</div>
              </td>
              <td rowspan="3" colspan="2">40*40*160</td>
              <td>
                <el-input
                  type="number"
                  v-model="form.kangzqd28phhz1"
                  @change="calculateSyrq(1, form.kangzqd28phhz1)"
                  @keydown.native="handleKeyDown($event, 5, 0)"
                  @paste.native="handlePasteTwo($event, 3, 0)"
                  :ref="'5_0'"
                />
              </td>
              <td>
                <span>{{ form.kangzqd28dz1 }}</span>
              </td>
              <td rowspan="3">
                <span>{{ form.kangzqd28pjz }}</span>
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input
                  type="number"
                  v-model="form.kangzqd28phhz2"
                  @change="calculateSyrq(2, form.kangzqd28phhz2)"
                  @keydown.native="handleKeyDown($event, 6, 0)"
                  @paste.native="handlePasteTwo($event, 4, 0)"
                  :ref="'6_0'"
                />
              </td>
              <td>
                <span>{{ form.kangzqd28dz2 }}</span>
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input
                  type="number"
                  v-model="form.kangzqd28phhz3"
                  @change="calculateSyrq(3, form.kangzqd28phhz3)"
                  @keydown.native="handleKeyDown($event, 7, 0)"
                  @paste.native="handlePasteTwo($event, 5, 0)"
                  :ref="'7_0'"
                />
              </td>
              <td>
                <span>{{ form.kangzqd28dz3 }}</span>
              </td>
            </tr>
            <tr height="25">
              <td rowspan="13">抗压强度</td>
              <td>龄期(d)</td>
              <td>试验日期</td>
              <td colspan="2">试件尺寸(mm)</td>
              <td>破坏荷载(kN)</td>
              <td>单值(Mpa)</td>
              <td>平均值(Mpa)</td>
            </tr>
            <tr height="25">
              <td rowspan="6">3</td>
              <td rowspan="6" class="line-feed-date">
                <!-- <el-date-picker type="datetime" class="hide-icon" v-model="form.kangyqd3syrq" style="width: 100%" /> -->
                <el-date-picker class="hide-icon" ref="kangyqd3syrq" type="datetime" v-model="form.kangyqd3syrq" value-format="yyyy/MM/dd HH:mm" format="yyyy/MM/dd HH:mm" style="width: 100%" />
                <div class="date-view" @click="$refs.kangyqd3syrq.focus()">{{ form.kangyqd3syrq }}</div>
              </td>
              <td rowspan="6" colspan="2">1600</td>
              <td>
                <el-input
                  type="number"
                  v-model="form.kangyqd3phhz1"
                  @change="calculateKyqd1(1, form.kangyqd3phhz1)"
                  @keydown.native="handleKeyDown($event, 8, 0)"
                  @paste.native="handlePasteTwo($event, 6, 0)"
                  :ref="'8_0'"
                />
              </td>
              <td>
                <span>{{ form.kangyqd3dz1 }}</span>
              </td>
              <td rowspan="6">
                <span>{{ form.kangyqd3pjz }}</span>
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input
                  type="number"
                  v-model="form.kangyqd3phhz2"
                  @change="calculateKyqd1(2, form.kangyqd3phhz2)"
                  @keydown.native="handleKeyDown($event, 9, 0)"
                  @paste.native="handlePasteTwo($event, 7, 0)"
                  :ref="'9_0'"
                />
              </td>
              <td>
                <span>{{ form.kangyqd3dz2 }}</span>
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input
                  type="number"
                  v-model="form.kangyqd3phhz3"
                  @change="calculateKyqd1(3, form.kangyqd3phhz3)"
                  @keydown.native="handleKeyDown($event, 10, 0)"
                  @paste.native="handlePasteTwo($event, 8, 0)"
                  :ref="'10_0'"
                />
              </td>
              <td>
                <span>{{ form.kangyqd3dz3 }}</span>
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input
                  type="number"
                  v-model="form.kangyqd3phhz4"
                  @change="calculateKyqd1(4, form.kangyqd3phhz4)"
                  @keydown.native="handleKeyDown($event, 11, 0)"
                  @paste.native="handlePasteTwo($event, 9, 0)"
                  :ref="'11_0'"
                />
              </td>
              <td>
                <span>{{ form.kangyqd3dz4 }}</span>
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input
                  type="number"
                  v-model="form.kangyqd3phhz5"
                  @change="calculateKyqd1(5, form.kangyqd3phhz5)"
                  @keydown.native="handleKeyDown($event, 12, 0)"
                  @paste.native="handlePasteTwo($event, 10, 0)"
                  :ref="'12_0'"
                />
              </td>
              <td>
                <span>{{ form.kangyqd3dz5 }}</span>
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input
                  type="number"
                  v-model="form.kangyqd3phhz6"
                  @change="calculateKyqd1(6, form.kangyqd3phhz6)"
                  @keydown.native="handleKeyDown($event, 13, 0)"
                  @paste.native="handlePasteTwo($event, 11, 0)"
                  :ref="'13_0'"
                />
              </td>
              <td>
                <span>{{ form.kangyqd3dz6 }}</span>
              </td>
            </tr>
            <tr height="25">
              <td rowspan="6">28</td>
              <td rowspan="6" class="line-feed-date">
                <!-- <el-date-picker type="datetime" class="hide-icon" v-model="form.kangyqd28syrq" style="width: 100%" /> -->
                <el-date-picker class="hide-icon" ref="kangyqd28syrq" type="datetime" v-model="form.kangyqd28syrq" value-format="yyyy/MM/dd HH:mm" format="yyyy/MM/dd HH:mm" style="width: 100%" />
                <div class="date-view" @click="$refs.kangyqd28syrq.focus()">{{ form.kangyqd28syrq }}</div>
              </td>
              <td rowspan="6" colspan="2">1600</td>
              <td>
                <el-input
                  type="number"
                  v-model="form.kangyqd28phhz1"
                  @change="calculateKyqd2(1, form.kangyqd28phhz1)"
                  @keydown.native="handleKeyDown($event, 14, 0)"
                  @paste.native="handlePasteTwo($event, 12, 0)"
                  :ref="'14_0'"
                />
              </td>
              <td>
                <span>{{ form.kangyqd28dz1 }}</span>
              </td>
              <td rowspan="6">
                <span>{{ form.kangyqd28pjz }}</span>
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input
                  type="number"
                  v-model="form.kangyqd28phhz2"
                  @change="calculateKyqd2(2, form.kangyqd28phhz2)"
                  @keydown.native="handleKeyDown($event, 15, 0)"
                  @paste.native="handlePasteTwo($event, 13, 0)"
                  :ref="'15_0'"
                />
              </td>
              <td>
                <span>{{ form.kangyqd28dz2 }}</span>
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input
                  type="number"
                  v-model="form.kangyqd28phhz3"
                  @change="calculateKyqd2(3, form.kangyqd28phhz3)"
                  @keydown.native="handleKeyDown($event, 16, 0)"
                  @paste.native="handlePasteTwo($event, 14, 0)"
                  :ref="'16_0'"
                />
              </td>
              <td>
                <span>{{ form.kangyqd28dz3 }}</span>
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input
                  type="number"
                  v-model="form.kangyqd28phhz4"
                  @change="calculateKyqd2(4, form.kangyqd28phhz4)"
                  @keydown.native="handleKeyDown($event, 17, 0)"
                  @paste.native="handlePasteTwo($event, 15, 0)"
                  :ref="'17_0'"
                />
              </td>
              <td>
                <span>{{ form.kangyqd28dz4 }}</span>
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input
                  type="number"
                  v-model="form.kangyqd28phhz5"
                  @change="calculateKyqd2(5, form.kangyqd28phhz5)"
                  @keydown.native="handleKeyDown($event, 18, 0)"
                  @paste.native="handlePasteTwo($event, 16, 0)"
                  :ref="'18_0'"
                />
              </td>
              <td>
                <span>{{ form.kangyqd28dz5 }}</span>
              </td>
            </tr>
            <tr height="25">
              <td>
                <el-input
                  type="number"
                  v-model="form.kangyqd28phhz6"
                  @change="calculateKyqd2(6, form.kangyqd28phhz6)"
                  @keydown.native="handleKeyDown($event, 19, 0)"
                  @paste.native="handlePasteTwo($event, 17, 0)"
                  :ref="'19_0'"
                />
              </td>
              <td>
                <span>{{ form.kangyqd28dz6 }}</span>
              </td>
            </tr>
          </tbody>
        </table>
        <!------------------------------附加声明-------------------------->
        <table height="30px" class="bottom-table">
          <tr>
            <td>
              <span v-if="isPdf" class="textarea-span">{{ form.fujsm }}</span>
              <el-input v-else type="textarea" :rows="2" v-model="form.fujsm" @focus="handleFocus('fujsm')" />
            </td>
          </tr>
        </table>
      </div>
      <!------------------------------表底-------------------------->
      <table height="22px" class="transparent">
        <tbody>
          <tr>
            <td width="10%" align="right">检测：</td>
            <td width="15%" align="left"></td>
            <td width="10%" align="right">记录：</td>
            <td width="15%" align="left"></td>
            <td width="10%" align="right">复核：</td>
            <td align="left" width="15%"></td>
            <td width="10%">日期：</td>
            <td align="left" width="15%">
              <div style="display: inline-block; margin-left: 20px">年</div>
              <div style="display: inline-block; margin-left: 20px">月</div>
              <div style="display: inline-block; margin-left: 20px">日</div>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
    <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
    <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType"></bs-judge-base-view>
  </div>
</template>

<script>
import { getSnjsjcjlbBsInfo } from "@/api/report_sn/snjsjcjlbBsInfo";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView.vue";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView.vue";
import { emptyConvert, handleFocus, calculateMeanvalue, handleKeyDown, handlePaste } from "@/views/reportForms/utils";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";
import Bus from "@/utils/bus";
import decimal from "@/utils/big-decimal";

export default {
  name: "snjsjcjlb",
  components: {
    BsInstrumentView,
    BsJiancyjView,
    BsJudgeBaseView
  },
  props: {
    excelId: {
      type: [String, Number],
      default: () => ""
    },
    syType: {
      type: [String, Number],
      default: () => ""
    },
    page: {
      type: Number,
      default: () => 0
    },
    isPdf: {
      type: Boolean,
      default: () => false
    },
    printEmpty: {
      type: Boolean,
      default: () => false
    }
  },
  data() {
    return {
      params: {},
      query: {},
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        excelId: [{ required: true, message: "主键不能为空", trigger: "blur" }]
      }
    };
  },

  created() {
    this.getInfo();
  },
  methods: {
    // 获取详情
    getInfo() {
      console.log(this.excelId);

      getSnjsjcjlbBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
        this.form = response.data;
        if (!this.form.fujsm) {
          this.form.fujsm = "附加声明：";
        }
      });
    },

    // 显示检测依据列表
    showBsJiancyjView() {
      this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
    },
    // 检测依据选择
    selectJiancyj(info) {
      this.form.jiancyj = info.label;
      this.form.jiancyjIds = info.ids;
      Bus.$emit("setSnBgJiancyj", { jiancyj: this.form.jiancyj, jiancyjIds: this.form.jiancyjIds });
    },

    // 显示判定依据列表
    showBsJudgeBaseView() {
      this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
    },
    // 判断依据选择
    selectJudge(info) {
       this.form.pandyjIds = info.ids;
      this.form.pandyj = info.label;
    },

    // 显示仪器列表
    showBsInstrumentView() {
      this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
    },
    // 仪器选择
    selectInstrument(info) {
      this.form.zhuyyqsbmcjbh = info.label;
      this.form.shebIds = info.ids;
      Bus.$emit("setSnBgZhuyyqsbmcjbh", { zhuyyqsbmcjbh: this.form.zhuyyqsbmcjbh, shebIds: this.form.shebIds });
    },

    //计算标准稠度用水量
    calculatePhhz(num, val) {
      let a3 = this.form["kangzqd3phhz" + num];
      if (a3) {
        // this.form["kangzqd3dz" + num] = decimal.round((1.5 * 1000 * a3 * 100) / 64000, 1);
        this.form["kangzqd3dz" + num] = decimal.round((1.5 * a3 * 100) / 64000, 1);
      } else {
        this.form["kangzqd3dz" + num] = null;
      }
      let arr3 = [this.form.kangzqd3dz1, this.form.kangzqd3dz2, this.form.kangzqd3dz3];
      arr3 = arr3.filter((v) => v != null);
      this.form.kangzqd3pjz = calculateMeanvalue(arr3, 1);
      // 抗折3d
      Bus.$emit("setSNBgJiancjgKzKy", [
        {
          key: 79,
          value: this.form.kangzqd3pjz,
          v1: this.form.kangzqd3dz1,
          v2: this.form.kangzqd3dz2,
          v3: this.form.kangzqd3dz3
        }
      ]);
    },
    calculateSyrq(num, val) {
      let a28 = this.form["kangzqd28phhz" + num];
      if (a28) {
        this.form["kangzqd28dz" + num] = decimal.round((1.5 * 1000 * a28 * 100) / 64000, 1);
      } else {
        this.form["kangzqd28dz" + num] = null;
      }
      let arr28 = [this.form.kangzqd28dz1, this.form.kangzqd28dz2, this.form.kangzqd28dz3];
      arr28 = arr28.filter((v) => v != null);
      this.form.kangzqd28pjz = calculateMeanvalue(arr28, 1);
      // 抗折28d
      Bus.$emit("setSNBgJiancjgKzKy", [
        {
          key: 80,
          value: this.form.kangzqd28pjz,
          v1: this.form.kangzqd28dz1,
          v2: this.form.kangzqd28dz2,
          v3: this.form.kangzqd28dz3
        }
      ]);
    },
    calculateKyqd1(num, val) {
      let a3 = this.form["kangyqd3phhz" + num];
      if (a3) {
        this.form["kangyqd3dz" + num] = decimal.round((a3 * 1000) / 1600, 1);
      } else {
        this.form["kangyqd3dz" + num] = null;
      }
      let ky3Arr = [this.form.kangyqd3dz1, this.form.kangyqd3dz2, this.form.kangyqd3dz3, this.form.kangyqd3dz4, this.form.kangyqd3dz5, this.form.kangyqd3dz6];
      ky3Arr = ky3Arr.filter((v) => v != null);
      this.form.kangyqd3pjz = calculateMeanvalue(ky3Arr, 1);
      // 抗压3d
      Bus.$emit("setSNBgJiancjgKzKy", [
        {
          key: 81,
          value: this.form.kangyqd3pjz,
          v1: this.form.kangyqd3dz1,
          v2: this.form.kangyqd3dz2,
          v3: this.form.kangyqd3dz3,
          v4: this.form.kangyqd3dz4,
          v5: this.form.kangyqd3dz5,
          v6: this.form.kangyqd3dz6
        }
      ]);
    },

    calculateKyqd2(num, val) {
      let ky28 = this.form["kangyqd28phhz" + num];
      if (ky28) {
        this.form["kangyqd28dz" + num] = decimal.round((ky28 * 1000) / 1600, 1);
      } else {
        this.form["kangyqd28dz" + num] = null;
      }
      let ky28Arr = [this.form.kangyqd28dz1, this.form.kangyqd28dz2, this.form.kangyqd28dz3, this.form.kangyqd28dz4, this.form.kangyqd28dz5, this.form.kangyqd28dz6];
      ky28Arr = ky28Arr.filter((v) => v != null);
      this.form.kangyqd28pjz = calculateMeanvalue(ky28Arr, 1);
      // 抗压28d
      Bus.$emit("setSNBgJiancjgKzKy", [
        {
          key: 82,
          value: this.form.kangyqd28pjz,
          v1: this.form.kangyqd28dz1,
          v2: this.form.kangyqd28dz2,
          v3: this.form.kangyqd28dz3,
          v4: this.form.kangyqd28dz4,
          v5: this.form.kangyqd28dz5,
          v6: this.form.kangyqd28dz6
        }
      ]);
    },

    handleFocus(event) {
      handleFocus(event, this.page, this.form[event]);
    },
    calculateJslddcdz(val) {
      // 胶砂流动度测定值(mm)
      Bus.$emit("setSNBgJiancjg", [
        {
          key: 83,
          value: val
        }
      ]);
    },
    submitForm() {
      return this.form;
    },
    handleKeyDown(event, rowIndex, colIndex) {
      const maxArr = [7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // 每一行最多有多少可聚焦输入框（从0开始）
      const ref = handleKeyDown(event, rowIndex, colIndex, maxArr);
      if (this.$refs[ref]) {
        this.$refs[ref].focus();
      }
    },
    // 粘贴赋值方法-胶砂流动度
    handlePaste(event, rowIndex, colIndex) {
      const nameAllArr = [["jiaoslddsycs", "jiaoslddsnyl", "jiaoslddbzsyl", "jiaoslddysl", "jiaoslddkzzj", "jiaoslddczzj", "jiaoslddjslddcz", "jiaoslddjslddcdz"]];
      const subscriptArr = [[0, 1, 2, 3, 4, 5, 6, 7]];

      const methodsAllArr = [[null, null, null, null, null, null, null, "calculateJslddcdz"]];
      const parameterArr = [[null, null, null, null, null, null, null, null]];
      const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
      const { cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr } = data;
      for (let a = 0; a < nameSetArr.length; a++) {
        for (let b = 0; b < nameSetArr[a].length; b++) {
          this.form[nameSetArr[a][b]] = cols[a][b];
        }
      }
      for (let a = 0; a < methodsSetArr.length; a++) {
        for (let b = 0; b < methodsSetArr[a].length; b++) {
          if (methodsSetArr[a][b]) {
            this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
          }
        }
      }
    },

    // 粘贴赋值方法-抗折强度、抗压强度
    handlePasteTwo(event, rowIndex, colIndex) {
      const nameAllArr = [
        ["kangzqd3phhz1"],
        ["kangzqd3phhz2"],
        ["kangzqd3phhz3"],
        ["kangzqd28phhz1"],
        ["kangzqd28phhz2"],
        ["kangzqd28phhz3"],
        ["kangyqd3phhz1"],
        ["kangyqd3phhz2"],
        ["kangyqd3phhz3"],
        ["kangyqd3phhz4"],
        ["kangyqd3phhz5"],
        ["kangyqd3phhz6"],
        ["kangyqd28phhz1"],
        ["kangyqd28phhz2"],
        ["kangyqd28phhz3"],
        ["kangyqd28phhz4"],
        ["kangyqd28phhz5"],
        ["kangyqd28phhz6"]
      ];
      const subscriptArr = [[0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0]];

      const methodsAllArr = [
        ["calculatePhhz"],
        ["calculatePhhz"],
        ["calculatePhhz"],
        ["calculateSyrq"],
        ["calculateSyrq"],
        ["calculateSyrq"],
        ["calculateKyqd1"],
        ["calculateKyqd1"],
        ["calculateKyqd1"],
        ["calculateKyqd1"],
        ["calculateKyqd1"],
        ["calculateKyqd1"],
        ["calculateKyqd2"],
        ["calculateKyqd2"],
        ["calculateKyqd2"],
        ["calculateKyqd2"],
        ["calculateKyqd2"],
        ["calculateKyqd2"]
      ];
      const parameterArr = [
        ["1-" + this.form.kangzqd3phhz1],
        ["2-" + this.form.kangzqd3phhz2],
        ["3-" + this.form.kangzqd3phhz3],
        ["1-" + this.form.kangzqd28phhz1],
        ["2-" + this.form.kangzqd28phhz2],
        ["3-" + this.form.kangzqd28phhz3],
        ["1-" + this.form.kangyqd3phhz1],
        ["2-" + this.form.kangyqd3phhz2],
        ["3-" + this.form.kangyqd3phhz3],
        ["4-" + this.form.kangyqd3phhz4],
        ["5-" + this.form.kangyqd3phhz5],
        ["6-" + this.form.kangyqd3phhz6],
        ["1-" + this.form.kangyqd28phhz1],
        ["2-" + this.form.kangyqd28phhz2],
        ["3-" + this.form.kangyqd28phhz3],
        ["4-" + this.form.kangyqd28phhz4],
        ["5-" + this.form.kangyqd28phhz5],
        ["6-" + this.form.kangyqd28phhz6]
      ];
      const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
      const { cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr } = data;
      for (let a = 0; a < nameSetArr.length; a++) {
        for (let b = 0; b < nameSetArr[a].length; b++) {
          this.form[nameSetArr[a][b]] = cols[a][b];
        }
      }
      for (let a = 0; a < methodsSetArr.length; a++) {
        for (let b = 0; b < methodsSetArr[a].length; b++) {
          if (methodsSetArr[a][b]) {
            let parameter = parameterSetArr[a][b];
            let parameterArr = parameter ? parameter.split("-") : [];
            if (parameterArr.length >= 2) {
              this.setCalculate(methodsSetArr[a][b], parameterArr[0], parameterArr[1]);
            }
          }
        }
      }
    },

    // 计算方法调用
    setCalculate(name, a, b, c, d, e) {
      this[name](a, b, c, d, e);
    },
    Introduction(dataJson) {
      const setDataJson = JSON.parse(dataJson);
      if (setDataJson) {
        console.log(setDataJson);
        this.form.kangzqd3syrq = "2024/11/20 11:20";
        this.form.kangzqd3phhz1 = "1.0";
        this.form.kangzqd3dz1 = "2.3";
        this.form.kangzqd3phhz2 = "2.18";
        this.form.kangzqd3dz2 = "5.1";
        this.form.kangzqd3phhz3 = "2.34";
        this.form.kangzqd3dz3 = "5.5";
        this.form.kangzqd3pjz = "4.3";

        this.form.kangzqd28syrq = "2024/11/20 11:20";
        this.form.kangzqd28phhz1 = "1.0";
        this.form.kangzqd28dz1 = "2.3";
        this.form.kangzqd28phhz2 = "3.33";
        this.form.kangzqd28dz2 = "7.8";
        this.form.kangzqd28phhz3 = "3.45";
        this.form.kangzqd28dz3 = "8.1";
        this.form.kangzqd28pjz = "6.1";
      }
    }
  }
};
</script>

<style scoped></style>
<style scoped lang="scss">
.td-input {
  width: 100% !important;
  height: 30px !important;
}

// 用于选择时间超出input无法换行的解决方案
.line-feed-date {
  position: relative;

  .date-view {
    width: 100%;
    height: 100%;
    position: absolute;
    z-index: 99;
    top: 0;
    background-color: #ffffff;
    display: flex;
    align-items: center;
  }
}
</style>
